package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.StatsCommodityStockRecordService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.StatsCommodityStockRecordDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 龙 路 飞
 * @CreateDate: 2023-08-31 18:00
 * @Description:
 */
@RestController
@RequestMapping("/api/statsCommodityStockRecord")
public class StatsCommodityStockRecordController extends UserInfoController {
    @Autowired
    private StatsCommodityStockRecordService statsCommodityStockRecordService;

    /**
     * 根据条件查询统计商品库存集合
     */
    @PostMapping("/findStatsCommodityStockRecordList")
    public ServerResponse findStatsCommodityStockRecordList(@RequestBody StatsCommodityStockRecordDto statsCommodityStockRecordDto, HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        statsCommodityStockRecordDto.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(statsCommodityStockRecordService.findStatsCommodityStockRecordList(statsCommodityStockRecordDto));
    }
    /**
     * 根据条件查询统计商品库存集合
     */
    @PostMapping("/findStatsCommodityStockRecordSum")
    public ServerResponse findStatsCommodityStockRecordSum(@RequestBody StatsCommodityStockRecordDto statsCommodityStockRecordDto, HttpServletRequest request){
        UserInfo userInfo = super.getLoginUserInfo(request);
        statsCommodityStockRecordDto.setUserInfo(userInfo);
        return ServerResponse.createBySuccess(statsCommodityStockRecordService.findStatsCommodityStockRecordSum(statsCommodityStockRecordDto));
    }
}
